package design_patterns;

/**
 * 代理模式
 * @author Fairy
 */
public class ProxyPattern {
    public static void main(String[] args) {
        Proxy proxy = new Proxy();
        proxy.request();
    }
}

/**
 * 共用接口
 */
abstract class Subject {
    public abstract void request();
}

/**
 * 真实对象
 */
class RealSubject extends Subject {

    @Override
    public void request() {
        System.out.println("真实的请求");
    }
}

/**
 * 代理对象
 */
class Proxy extends Subject {
    RealSubject realSubject;
    @Override
    public void request() {
        if (realSubject == null) {
            realSubject = new RealSubject();
        }
        realSubject.request();
    }
}